home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / snpd0493.zip / ISNETDR.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  1KB  |  46 lines

  1. /*----------------------------------------------------------------------*/
  2. /*  determine_drive_type -- Public Domain code from Bob Dolan           */
  3. /*                                                                      */
  4. /*  INPUT:  the drive number ( 0=current, 1=A:, 2=B:, etc. )            */
  5. /*  OUTPUT: drive type ( 0=physical drive, 1=Network drive, 2=RamDisk ) */
  6. /*----------------------------------------------------------------------*/
  7.  
  8. #include <dos.h>
  9.  
  10. drive_type(int dr)
  11. {
  12.       union REGS regs;
  13.  
  14.       regs.x.ax = 0x4409;     /* IOCTL func 9 */
  15.       regs.h.bl = (unsigned char)dr;
  16.       int86(0x21, ®s, ®s);
  17.       if (!regs.x.cflag)
  18.       {
  19.             if (regs.x.dx & 0x1000)
  20.                   return 1;   /* Network drive */
  21.  
  22.             else if (regs.x.dx == 0x0800)
  23.                   return 2;   /* RAMdisk */
  24.       }
  25.  
  26.       return 0;   /* physical drive */
  27. }
  28.  
  29. #ifdef TEST
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <ctype.h>
  34.  
  35. int main(int argc, char *argv[])
  36. {
  37.       int dr = 0;
  38.  
  39.       if (1 < argc)
  40.             dr = toupper(*argv[1]) - '@';
  41.       printf ("drive_type(%d) = %d\n", dr, drive_type(dr));
  42.       return 0;
  43. }
  44.  
  45. #endif /* TEST */
  46.